package com.atguigu.gulimall.order.web;

import com.atguigu.gulimall.order.entity.OmsOrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @author ming
 * @create 2022/5/8
 * @description:
 */
@Controller
public class HelloController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @GetMapping("/{page}.html")
    public String listPage(@PathVariable("page") String page){
        return page;
    }
    @GetMapping("/test/crateOrder")
    @ResponseBody
    public String crateOrderTest(){
        OmsOrderEntity orderEntity = new OmsOrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString());
        orderEntity.setModifyTime(new Date());
        //发送消息
        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);
        return "ok";
    }
    
}
